package com.jy.api.controller.admin;

import com.jy.api.service.ProductTypeService;
import com.jy.api.service.SetMealService;
import com.jy.api.signUpReq.admin.SetMealReq;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

/**
 * Created by xiaohua on 2019/3/1.
 */
@Slf4j
@RestController
@RequestMapping(value = "v1/admin/meal", produces = "application/json;charset=utf-8")
public class SetMealController {
    @Autowired
    private SetMealService setMealService;


    /**
     * 得到店铺下的所有套餐
     *
     * @param storeId
     * @return
     */
    @GetMapping("get-meal")
    public ResponseEntity getSetMeal(@RequestParam("storeId") String storeId) {
        return ResponseEntity.ok(setMealService.findSetMealByStoreId(storeId));
    }

    /**
     * 删除套餐
     *
     * @param req
     * @return
     */
    @PostMapping("delete-meal")
    public ResponseEntity deleteMeal(@RequestBody SetMealReq req) {
        return ResponseEntity.ok(setMealService.deleteSetMeal(req));
    }

    /**
     * 添加套餐
     *
     * @param req
     * @return
     */
    @PostMapping("add-meal")
    public ResponseEntity addMeal(@RequestBody SetMealReq req) {
        return ResponseEntity.ok(setMealService.addSetMeal(req));
    }

    /**
     * 修改套餐
     *
     * @param req
     * @return
     */
    @PostMapping("update-meal")
    public ResponseEntity updateMeal(@RequestBody SetMealReq req) {
        return ResponseEntity.ok(setMealService.updateSetMeal(req));
    }

    /**
     * 删除套餐下的商品
     *
     * @param req
     * @return
     */
    @PostMapping("delete-pro")
    public ResponseEntity deletePro(@RequestBody SetMealReq req) {
        return ResponseEntity.ok(setMealService.deleteProductByMealId(req));
    }

    /**
     * 添加套餐下的商品
     *
     * @param req
     * @return
     */
    @PostMapping("add-pro")
    public ResponseEntity addPro(@RequestBody SetMealReq req) {
        return ResponseEntity.ok(setMealService.addProductByMealId(req));
    }

    /**
     * 通过套餐ID查询商品列表
     *
     * @param mealId
     * @return
     */
    @GetMapping("find-pro")
    public ResponseEntity findPro(@RequestParam("mealId") int mealId) {
        return ResponseEntity.ok(setMealService.findProductByMealId(mealId));
    }


}
